<template>
     <div class="components-container">
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
         <el-tab-pane label="查询条件" name="search">
            <div :style="{maxHeight:maxHeight+'px'}" style="overflow:auto;">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                        <label class="layui-form-label" >业务编号</label>
                            <div class="layui-input-inline">
                            <el-input v-model="selectData.RegbussnumLike" placeholder="请输入业务编号"></el-input>
                            </div>
                        </div>
                    
                        <div class="layui-inline">
                            <label class="layui-form-label" >火化日期</label>
                            <el-date-picker v-date v-model="selectData.RegcremationdateGreaterAndEquals" type="date" placeholder="选择日期范围" >
                            </el-date-picker>
                            <el-date-picker v-date v-model="selectData.RegcremationdateLessAndEquals" type="date" placeholder="选择日期范围">
                            </el-date-picker>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">统计地点</label>
                            <div class="layui-input-inline">
                            <el-cascader :options="area" v-model="RegaddidEqualss" filterable :show-all-levels="false" change-on-select>
                            </el-cascader>
                            </div>
                        </div>
                        <!-- <el-button type="primary" :disabled="downloadLoading" @click="btnSearch" :loading="this.$store.state.isloading">搜索</el-button>
                        <el-button :disabled="this.$store.state.isloading || downloadLoading"  @click="btnRepeat">重置</el-button> -->
                    </div>
                    <div class="layui-form-item">
                       <div class="layui-inline">
                            <label class="layui-form-label" >逝者姓名</label>
                            <div class="layui-input-inline">
                                <el-input v-model="selectData.RegnameLike" placeholder="请输入逝者姓名"></el-input>
                            </div>
                        </div>
                        <!-- <div class="layui-inline">
                            <label class="layui-form-label" >逝者性别</label>
                            <div class="layui-input-inline">
                                <el-input v-model="selectData.RegnameLike" placeholder="请输入逝者性别"></el-input>
                            </div>
                        </div> -->
                        <div class="layui-inline">
                          <label class="layui-form-label">逝者性别</label>
                          <div class="layui-input-inline">
                            <el-select v-model="selectData.RegsexEquals" filterable>
                              <el-option v-for="item in xblxs" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                              </el-option>
                            </el-select>
                          </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">家属姓名</label>
                            <div class="layui-input-inline">
                            <el-input v-model="selectData.ReghandlernameLike" placeholder="请输入家属姓名"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">联系电话</label>
                            <div class="layui-input-inline">
                            <el-input v-model="selectData.ReghandlerlinkEquals" placeholder="请输入联系电话"></el-input>
                            </div>
                        </div>
                    </div>

                     <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" >身份证号</label>
                            <div class="layui-input-inline">
                                <el-input v-model="selectData.RegCardnoEquals" placeholder="请输入身份证号码"></el-input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">户籍地址</label>
                            <div class="layui-input-inline">
                              <el-cascader :options="areas" v-model="RegHouseholeEquals" filterable :show-all-levels="false">
                              </el-cascader>
                            </div>
                        </div>
                        <div class="layui-inline">
                          <label class="layui-form-label">收费状态</label>
                          <div class="layui-input-inline">
                            <el-select v-model="selectData.ChdStatusEquals" filterable>
                              <el-option v-for="item in xblx" :key="item.Value" :label="item.Text" :value="item.Value">
                              </el-option>
                            </el-select>
                          </div>
                        </div>
                        <div class="layui-inline">
                          <label class="layui-form-label" style="width:130px;">是否显示遗体外运</label>
                          <div class="layui-input-inline">
                            <el-select v-model="selectData.RegcurstatusUnEquals" filterable>
                              <el-option v-for="item in deadwyArray" :key="item.Value" :label="item.Text" :value="item.Value">
                              </el-option>
                            </el-select>
                          </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" >结账日期</label>
                            <!-- RegdateGreaterAndEquals
                            RegdateLessAndEquals -->
                            <el-date-picker v-date v-model="selectData.ChddateGreaterAndEquals" type="date" placeholder="选择日期范围" >
                            </el-date-picker>
                            <el-date-picker v-date v-model="selectData.ChddateLessAndEquals" type="date" placeholder="选择日期范围">
                            </el-date-picker>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" >接尸日期</label>
                            <!-- RegdateGreaterAndEquals
                            RegdateLessAndEquals -->
                            <el-date-picker v-date v-model="selectData.RegdateGreaterAndEquals" type="date" placeholder="选择日期范围" >
                            </el-date-picker>
                            <el-date-picker v-date v-model="selectData.RegdateLessAndEquals" type="date" placeholder="选择日期范围">
                            </el-date-picker>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" >年龄段</label>
                            <div class="layui-input-inline">
                              <el-input v-model="selectData.RegageGreaterAndEquals" placeholder="请输入起始年龄"></el-input>
                            </div>
                            <div class="layui-input-inline">
                              <el-input v-model="selectData.RegageLessAndEquals" placeholder="请输入结束年龄"></el-input>
                            </div>
                            <!-- <el-date-picker v-date v-model="selectData.RegdateGreaterAndEquals" type="date" placeholder="选择日期范围" >
                            </el-date-picker>
                            <el-date-picker v-date v-model="selectData.RegdateLessAndEquals" type="date" placeholder="选择日期范围">
                            </el-date-picker> -->
                        </div>
                    </div>

                   
              <div class="layui-form-item btnCenter">
                <el-button type="primary" :disabled="downloadLoading" @click="btnSearch" :loading="this.$store.state.isloading">搜索</el-button>
                <el-button :disabled="this.$store.state.isloading || downloadLoading"  @click="btnRepeat">重置</el-button>
            </div>
            </div>
            </el-tab-pane>
            <el-tab-pane label="查询结果" name="results">
                <div>
                  <ul class="toolList">
                    <li>
                      <el-button type="primary" :disabled="this.$store.state.isloading" @click="exportExcel" :loading="downloadLoading"  style="margin-left:20px;">导出Excel</el-button>
                    </li>
                    <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                      <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                    </li>
                  </ul>
                </div>
                <!-- <dataTable :headList="headList" :dataList="dataList" :isIndex="true" :hiddenPageOrder="false" :height="height" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable> -->
                   <!--数据列表-->
                <el-table
                :data="dataList"
                ref="multipleTable"
                @cell-click="cellClick"
                style="width: 100%">
                <el-table-column type="expand">
                <template slot-scope="props">
                <el-table :data="list2" style="width: 100%;" >
                <el-table-column 
                    :prop="items.ColumnKey"
                    :label="items.ColumnName"
                    :order="items.ColumnOrder"
                    :align="items.ColumnAlign"
                    :width="items.ColumnWidth" 
                    :sortable="items.ColumnOrder==''?false:'custom'"
                    :key="indexs"
                    v-for="(items,indexs) in headList2">
                </el-table-column>
                </el-table>
                    <!-- <el-form label-position="left" inline class="demo-table-expand">
                    </el-form> -->
                </template>
                </el-table-column>
                <el-table-column 
                    :prop="item.ColumnKey"
                    :label="item.ColumnName"
                    :order="item.ColumnOrder"
                    :align="item.ColumnAlign"
                    :width="item.ColumnWidth" 
                    :sortable="item.ColumnOrder==''?false:'custom'"
                    :key="index"
                    v-for="(item,index) in headList">
                </el-table-column>
                </el-table>
                <printmodal ref="printPdf"></printmodal>
                <deadFileSearchreg ref="simpleReg" :orderType="order" @refreshData="getData"></deadFileSearchreg>
                <Appendixlists ref="dialog"></Appendixlists>
                <Appendixlisttwo ref="dialogs"></Appendixlisttwo>
                <cre-proof ref="prints"></cre-proof> 
            </el-tab-pane>
        </el-tabs>
        <el-dialog title="录音详情" :visible.sync="dialogTableVisible" :modal-append-to-body="false" width="60%">
            <el-table ref="multipleTable" :data="diechdData" tooltip-effect="dark" style="width: 100%" max-height="450" @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column prop="SDGTALKDATEDESC" label="通话日期" width="120"></el-table-column>
              <el-table-column prop="SDGTALKTIMEDESC" label="通话时间" width="120"></el-table-column>
              <el-table-column prop="SDGREMOTECODE" label="对方电话" width="180"></el-table-column>
              <el-table-column prop="read" label="播放录音"> <template slot-scope="scope"><audio :src="scope.row.SDGTALKURL" controls="controls">播放</audio></template></el-table-column>
            </el-table>
            <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click="toggleSelection()">取 消</el-button>
            </span>
        </el-dialog> 
     </div>
</template>

<script>
// import { export_json_to_excel } from "@/vendor/Export2Excel.js";
import dataTable from "@/components/Table/DataTable";
import deadFileSearchreg from "./deadFileSearchreg";
import apiBase from "@/api/apiBase.js";
import { ORDER } from "@/const/orderConst.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import printmodal from "@/components/Pdf/Print";
import { manage } from "@/mixins/managePage.js";
import { PRINT } from "@/components/Pdf/PDF.js";
import Appendixlists from "../jointPlatform/Appendixlists";
import Appendixlisttwo from "../jointPlatform/Appendixlisttwo";
import creProof from "./creproofDetail";

// import * as Export2Excel from '@/vendor/Export2Excel';


const INFO = "详情";
const EXPORT = "导出";
const CHANGE = "修改";
const COPY = '打印';
const REPRINT = "补打火化证明";
const REPRINTS = "补打联办单";

export default {
  name: "deadFileSearch",
  mixins: [manage],
  data() {
    return {
      selectData: {
        RegnameLike: null,
        RegsexEquals: null,
        ReghandlernameLike: null,
        ReghandlerlinkEquals: null,
        RegageGreaterAndEquals: null,
        RegageLessAndEquals: null,
        RegcremationdateGreaterAndEquals: null,
        RegcremationdateLessAndEquals: null,
        RegbussnumLike: null,
        ChddateGreaterAndEquals: null,
        ChddateLessAndEquals: null,
        RegdateGreaterAndEquals: null,
        RegdateLessAndEquals: null,
        RegCardnoEquals: null,
        ChdStatusEquals: null,
        RegcurstatusUnEquals: null,
      },
      deadwyArray: [
        {Text: '是', Value: null},
        {Text: '否', Value: "E"}
      ],
      area: [],
      areas: [],
      xblx: [],
      xblxs: [],
      dataLists: [],
      RegaddidEqualss: [],
      RegHouseholeEquals: [],
      diechdData:[],
      activeName: "search",
      maxHeight: 500,
      height: "620",
      downloadLoading:false,
      copyLoading:false,
      dialogTableVisible: false,
      list2:[],

    };
  },
  methods: {
    exportExcel() {
      var startTime;
      var endTime;
      if(this.selectData.RegcremationdateGreaterAndEquals){
         startTime = this.selectData.RegcremationdateGreaterAndEquals.toLocaleDateString();
      }else{
        startTime = '空';
      }
      if(this.selectData.RegcremationdateLessAndEquals){
         endTime = this.selectData.RegcremationdateLessAndEquals.toLocaleDateString();
      }else{
        endTime = '空';
      }
      let headername;
      let addrName;
      if(this.RegaddidEqualss.length == 0){
        addrName = '全部';
      }else if(this.RegaddidEqualss.length == 1){
        if(this.RegaddidEqualss[0] == '001'){
          addrName = '全部';
        }else{
          for(var i = 0;i < this.area.length;i++){
            if(this.area[i].value == this.RegaddidEqualss[0]){
              addrName = this.area[i].label;
            }
          }
        }
      }else if(this.RegaddidEqualss.length == 2){
        var copyarea = this.area;
        // copyarea.splice(0,1);
        let addrId = this.RegaddidEqualss[1];
        copyarea.forEach(function(value, index, arr) {
          value.children.forEach(function(v, i, a) {
            if (v.value == addrId) {
              addrName = v.label;
            }
          });
        });
      }
      headername = '逝者档案查询' + '__' + addrName + '(' + startTime + '-' + endTime + ')';
      if (this.dataList.length === 0){
          this.$message.error("无导出数据！");
          return;
      }
      this.downloadLoading = true;
      require.ensure([], () => {
        const { export_json_to_excel } = require("@/vendor/Export2Excel");
        export_json_to_excel(this.headList, this.dataLists, headername);
        this.downloadLoading = false;
      });
    },
    toggleSelection(rows) {
        this.dialogTableVisible = false;
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //功能操作
    operate(order) {
      this.copyLoading = true;
      this.order = order;
      switch (this.order) {
        case INFO:
          this.$refs.simpleReg.open(this.order, this.currentRow.REGID);
          break;
        case EXPORT:
          this.$refs.printPdf.report(PRINT.PDFDEADFILESEARCH, this.getDataC());
          break;
        case CHANGE:
          this.$refs.simpleReg.open(this.order, this.currentRow.REGID,this.currentRow.REGISCHECK);
          break;
        case COPY:
          this.$refs.printPdf.report(PRINT.PDFDEADFILESEARCH, this.getDataC());
          this.copyLoading = false;
          break;
        case "录音详情":
          this.diechdData = [];
          this.dialogTableVisible = true;
          this.detailSound();
          break;
        case "打印火化登记表":
          this.$refs.simpleReg.open(this.order,this.currentRow.CHDID);
          break;
        case "回传附件详情":
          this.$refs.dialog.operate('附件上传',this.currentRow.REGPRPID);//附件详情
          break;
        case "附件上传":
          this.$refs.dialogs.operate('附件上传',this.currentRow.REGID);//附件详情
          break;
        case REPRINT:
          this.title = "补打火化证明";
          if (this.currentRow)
            this.$refs.prints.open(this.order,this.currentRow.REGID,null,true);
          else alert("尚未选中行");
          break;
        case REPRINTS:
          this.title = "补打联办单";
          if (this.currentRow)
            this.$refs.prints.open(this.order,this.currentRow.REGID,null,true);
          else alert("尚未选中行");
          break;
        default:
      }
    },
    handleClick(tab, event) {
        if(tab.name == 'results'){
            this.btnSearch();
        }
    },
    getCode() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Registration.QueryAllCode,
        res => {
          this.codeList = res.data.content;
          for (var i in this.codeList) {
            switch (this.codeList[i].CTPID) {
              case "性别类型":
                this.xblxs = this.codeList[i].Cods;
                break;
              default:
            }
          }
        }
      );
    },
     //获取录音详情
    detailSound() {
      let data = {
        SDGPRPID: this.currentRow.REGID
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().SoundRecord.DetailSoundRecord,
        res => {
          this.diechdData = res.data.content.list_SDG;
          for(let index in this.diechdData){
              this.diechdData[index].SDGTALKDATEDESC = this.diechdData[index].SDGTALKDATEDESC;
              this.diechdData[index].SDGTALKTIMEDESC = this.diechdData[index].SDGTALKTIMEDESC; 
              this.diechdData[index].SDGREMOTECODE = this.diechdData[index].SDGREMOTECODE;
              // this.diechdData[index].read = '播放';
          }
        }
      );
    },
     //获取统计条件
   getAddr() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Code.GetAddressMap,
        res => {
          let cardata = res.data.content;
          this.area = cardata.map(item => ({
            value: item.ADDID,
            label: item.ADDNAME,
            ADDLEVEL: item.ADDLEVEL,
            ADDTOPID: item.ADDTOPID,
            children: item.Children.map(itemStr => ({
              value: itemStr.ADDID,
              label: itemStr.ADDNAME,
              ADDLEVEL: itemStr.ADDLEVEL,
              ADDTOPID: itemStr.ADDTOPID
            }))
          }));
          this.area.unshift({label:'全部',value: '001',children:[{label: '全部',value: null}]});
        }
      );
    },
    //获取户籍地址
    getAddress() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Code.GetHousehold,
        res => {
          let cardatas = res.data.content;
          this.areas = cardatas.map(item => ({
            value: item.StaCode,
            label: item.StaName,
            children: item.List_Cty.map(itemStr => ({
              value: itemStr.CtyCode,
              label: itemStr.CtyName,
              children: itemStr.List_Cnt.map(itemCnt => ({
                value: itemCnt.CntCode,
                label: itemCnt.CntName,
              }))
            }))
          }));
        }
      );
    },
    //获取收费状态
    getchargetate(){
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Checkout.GetChdStatuslittle,
        res => {
          this.xblx = res.data.content;
        }
      );
    },
    getDataC() {
       let Data = JSON.parse(JSON.stringify(this.selectData));
      if (!this.selectData.RegnameLike) {
        Data.RegnameLike = null;
      }
      if(!this.selectData.RegsexEquals){
        Data.RegsexEquals = null;
      }
      if (!this.selectData.ReghandlernameLike) {
        Data.ReghandlernameLike = null;
      }
      if(!this.selectData.RegbussnumLike){
        Data.RegbussnumLike = null;
      }
      if (!this.selectData.ReghandlerlinkEquals) {
        Data.ReghandlerlinkEquals = null;
      }
      // console.log(this.RegaddidEqualss);
      // if(!this.RegaddidEqualss){
      //   Data.RegaddidEquals = this.RegaddidEqualss;
      // }
      // Data.RegaddidEquals = this.RegaddidEqualss[1];

      if(this.RegaddidEqualss.length == 1){
        if(this.RegaddidEqualss[0] == '001'){
          Data.AddIdOr = null
        }else{
          Data.AddIdOr = this.RegaddidEqualss[0];
        }
      }else if(this.RegaddidEqualss.length == 2){
        Data.AddIdOr = this.RegaddidEqualss[1];
      }else{
        Data.AddIdOr = null;
      }

      // if(this.AddIdOr.length != 0){
      //   Data.AddIdOr = this.AddIdOr[this.AddIdOr.length-1];
      //   if(Data.AddIdOr == '001'){
      //     Data.AddIdOr = null;
      //   }
      // }else{
      //   Data.AddIdOr = null;
      // }

      if(!this.RegHouseholeEquals){
        Data.RegHouseholeEquals = this.RegHouseholeEquals;
      }
      Data.RegHouseholeEquals = this.RegHouseholeEquals[2];
      Data.RegcremationdateGreaterAndEquals = formatDate(
        Data.RegcremationdateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.RegcremationdateLessAndEquals = formatDate(
        Data.RegcremationdateLessAndEquals,
        "yyyyMMdd"
      );
      Data.ChddateGreaterAndEquals = formatDate(
        Data.ChddateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.ChddateLessAndEquals = formatDate(
        Data.ChddateLessAndEquals,
        "yyyyMMdd"
      );
      Data.RegdateGreaterAndEquals = formatDate(
        Data.RegdateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.RegdateLessAndEquals = formatDate(
        Data.RegdateLessAndEquals,
        "yyyyMMdd"
      );
      let data = {
        PageIndex: -1,
        PageSize: 1000,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: Data
      };
      return data;
    },
    cellClick(row, column, event) {
      if(event.cellIndex != 0){
      this.$refs.multipleTable.toggleRowExpansion(row)
      }
    },
    getColumns() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Column.GetDeadFileColumns,
        res => {
          this.headList = res.data.content;
        }
      );
      apiBase.DoService(data, apiBase.getApiAdress().Column.GetDeptColumns, res => {
        this.headList2 = res.data.content;
      });
    },
    //获取数据
    getData() {
      let Data = JSON.parse(JSON.stringify(this.selectData));
      if (!this.selectData.RegnameLike) {
        Data.RegnameLike = null;
      }
      if(!this.selectData.RegsexEquals){
        Data.RegsexEquals = null;
      }
      if (!this.selectData.ReghandlernameLike) {
        Data.ReghandlernameLike = null;
      }
      if(!this.selectData.RegbussnumLike){
        Data.RegbussnumLike = null;
      }
      if (!this.selectData.ReghandlerlinkEquals) {
        Data.ReghandlerlinkEquals = null;
      }
      // console.log(this.RegaddidEqualss);
      // if(!this.RegaddidEqualss){
      //   Data.RegaddidEquals = this.RegaddidEqualss;
      // }
      // Data.RegaddidEquals = this.RegaddidEqualss[1];

      if(this.RegaddidEqualss.length == 1){
        if(this.RegaddidEqualss[0] == '001'){
          Data.AddIdOr = null
        }else{
          Data.AddIdOr = this.RegaddidEqualss[0];
        }
      }else if(this.RegaddidEqualss.length == 2){
        Data.AddIdOr = this.RegaddidEqualss[1];
      }else{
        Data.AddIdOr = null;
      }

      // if(this.AddIdOr.length != 0){
      //   Data.AddIdOr = this.AddIdOr[this.AddIdOr.length-1];
      //   if(Data.AddIdOr == '001'){
      //     Data.AddIdOr = null;
      //   }
      // }else{
      //   Data.AddIdOr = null;
      // }

      if(!this.RegHouseholeEquals){
        Data.RegHouseholeEquals = this.RegHouseholeEquals;
      }
      Data.RegHouseholeEquals = this.RegHouseholeEquals[2];
      Data.RegcremationdateGreaterAndEquals = formatDate(
        Data.RegcremationdateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.RegcremationdateLessAndEquals = formatDate(
        Data.RegcremationdateLessAndEquals,
        "yyyyMMdd"
      );
      Data.ChddateGreaterAndEquals = formatDate(
        Data.ChddateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.ChddateLessAndEquals = formatDate(
        Data.ChddateLessAndEquals,
        "yyyyMMdd"
      );
      Data.RegdateGreaterAndEquals = formatDate(
        Data.RegdateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.RegdateLessAndEquals = formatDate(
        Data.RegdateLessAndEquals,
        "yyyyMMdd"
      );
      let data = {
        PageIndex: 1,
        PageSize: 1000,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: Data
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Registration.QueryHistoryFile,    
        res => {
          this.dataList = res.data.content.OutData;
        //   this.activeName = "results";
          this.pageOrder.totalNum = res.data.content.RecordCount;
        }
      );
      apiBase.DoService(data, apiBase.getApiAdress().Dept.Query, res => {
        this.list2 = res.data.content.OutData;
        this.pageOrder.totalNum = res.data.content.RecordCount;
      });
    },
    //因为展示1000条，打印全部所以要有这个方法。
    getAllData() {
      let Data = JSON.parse(JSON.stringify(this.selectData));
      if (!this.selectData.RegnameLike) {
        Data.RegnameLike = null;
      }
      if(!this.selectData.RegsexEquals){
        Data.RegsexEquals = null;
      }
      if (!this.selectData.ReghandlernameLike) {
        Data.ReghandlernameLike = null;
      }
      if(!this.selectData.RegbussnumLike){
        Data.RegbussnumLike = null;
      }
      if (!this.selectData.ReghandlerlinkEquals) {
        Data.ReghandlerlinkEquals = null;
      }
      // if(!this.RegaddidEqualss){
      //   Data.RegaddidEqualss = this.RegaddidEqualss;
      // }
      // Data.RegaddidEquals = this.RegaddidEqualss[1];
      if(this.RegaddidEqualss.length == 1){
        if(this.RegaddidEqualss[0] == '001'){
          Data.AddIdOr = null
        }else{
          Data.AddIdOr = this.RegaddidEqualss[0];
        }
      }else if(this.RegaddidEqualss.length == 2){
        Data.AddIdOr = this.RegaddidEqualss[1];
      }else{
        Data.AddIdOr = null;
      }


      if(!this.RegHouseholeEquals){
        Data.RegHouseholeEquals = this.RegHouseholeEquals;
      }
      Data.RegHouseholeEquals = this.RegHouseholeEquals[1];
      Data.RegcremationdateGreaterAndEquals = formatDate(
        Data.RegcremationdateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.RegcremationdateLessAndEquals = formatDate(
        Data.RegcremationdateLessAndEquals,
        "yyyyMMdd"
      );
       Data.ChddateGreaterAndEquals = formatDate(
        Data.ChddateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.ChddateLessAndEquals = formatDate(
        Data.ChddateLessAndEquals,
        "yyyyMMdd"
      );
      Data.RegdateGreaterAndEquals = formatDate(
        Data.RegdateGreaterAndEquals,
        "yyyyMMdd"
      );
      Data.RegdateLessAndEquals = formatDate(
        Data.RegdateLessAndEquals,
        "yyyyMMdd"
      );
      let data = {
        PageIndex: -1,
        PageSize: 1000,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: Data
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Registration.QueryHistoryFile,
        res => {
          this.dataLists = res.data.content.OutData;
        }
      );
    },
    btnShow(btn) {
      switch (btn) {
        case "导出":
          return true;
          break;
        case "修改":
          return true;
          break;
        case "打印":
          return true;
          break; 
        case "录音详情":
          if(this.currentRow) return true;
          break;
        case "打印火化登记表":
          if(this.currentRow) return true;
          break;
        case "回传附件详情":
          if(this.currentRow) return true;
          break;
        case "附件上传":
          if(this.currentRow) return true;
          break;
         case "补打火化证明":
          if(this.currentRow) return true;
          break;
         case "补打联办单":  
          if(this.currentRow) return true;
          break;
        default:
          return false;
      }
    },
    //搜索按钮
    btnSearch(){
        this.getData();
        this.getAllData();
        this.activeName = "results";
        this.$store.state.isloading = true;
    },
    //查询条件重置
    btnRepeat() {
      this.selectData = {
        RegnameLike: null,
        RegsexEquals: null,
        ReghandlernameLike: null,
        ReghandlerlinkEquals: null,
        RegcremationdateGreaterAndEquals: null,
        RegcremationdateLessAndEquals: null,
        RegbussnumLike: null,
        ChddateGreaterAndEquals: null,
        ChddateLessAndEquals: null,
        RegdateGreaterAndEquals: null,
        RegdateLessAndEquals: null,
        RegCardnoEquals: null,
        ChdStatusEquals: null,
      };
      this.RegaddidEqualss = [];
      this.RegHouseholeEquals = [];
    //   this.selectData.RegcremationdateGreaterAndEquals = new Date();
    //   this.selectData.RegcremationdateGreaterAndEquals.setDate(1);
    //   this.selectData.RegcremationdateLessAndEquals = new Date();
    //   var day = new Date();
    //   var year = day.getFullYear();
    //   var month = day.getMonth() + 1;
    //   var d = new Date(year, month, 0);
    //   var dat = d.getDate();
    //   this.selectData.RegcremationdateLessAndEquals.setDate(dat);
      this.getData();
    }
  },
  mounted() {},
  components: {
    dataTable,
    deadFileSearchreg,
    printmodal,
    Appendixlists,
    Appendixlisttwo,
    creProof
  },
  created() {
    // this.selectData.RegcremationdateGreaterAndEquals = new Date();
    // this.selectData.RegcremationdateGreaterAndEquals.setDate(1);
    // this.selectData.RegcremationdateLessAndEquals = new Date();
    // var day = new Date();
    // var year = day.getFullYear();
    // var month = day.getMonth() + 1;
    // var d = new Date(year, month, 0);
    // var dat = d.getDate();
    // this.selectData.RegcremationdateLessAndEquals.setDate(dat);
    this.getColumns();
    this.getData();
    this.getAllData();
    this.getAddr();
    this.getAddress();
    this.getchargetate();
    this.getCode();
  }
};
</script>

